package define.Demo_02.GirlFriend;

public class GirlFriendTest {
    public static void main(String[] args) {
        //创建对象
        GirlFriend gf1 = new GirlFriend("小王",22,'女',"打游戏");
        GirlFriend gf2 = new GirlFriend("小李",20,'女',"听音乐");
        GirlFriend gf3 = new GirlFriend("小刘",24,'女',"看电影");
        GirlFriend gf4 = new GirlFriend("小A",18,'女',"打篮球");
        //创建数组
        GirlFriend [] arr = new GirlFriend[4];
        //将对象放入数组
        arr[0] = gf1;
        arr[1] = gf2;
        arr[2] = gf3;
        arr[3] = gf4;
        //遍历数组

        int sum = 0,avg=0;
        for (int i = 0; i < arr.length; i++) {
            GirlFriend gf = arr[i];
            sum += gf.getAge();
        }
        avg = sum / arr.length;
        System.out.println(avg);
        int temp =0;
        for (int i = 0; i < arr.length; i++) {
            temp= arr[i].getAge();
            if (avg > temp) {
                System.out.println(arr[i].toString());
            }
        }
    }
}
